package FileStudy;

import java.io.File;
import java.io.IOException;

//File的构造
public class Fdemo1 {
        public static void main(String[] args) throws IOException {
        File file1 = new File("D:/test.txt");//绝对路径
            System.out.println(file1.getParent());
            System.out.println(file1.getName());
            System.out.println(file1.getPath());
            System.out.println(file1.getAbsolutePath());
            System.out.println(file1.getCanonicalPath());

            System.out.println("-------------------------");

        File file2 = new File("./test.txt");//相对路径
            System.out.println(file2.getParent());
            System.out.println(file2.getName());
            System.out.println(file2.getPath());
            System.out.println(file2.getAbsolutePath());
            System.out.println(file2.getCanonicalPath());
        //此处写的./test.txt在IDEA下运行就是找在当前java项目中下的test.txt文件。
    }
}
